<?php
        $action_url='C=addons_modules&M=show_module_cp&module=spider&method=apiConfigure';
        $changeUrl=$action_url;
        $action_url .='&api='.$currentApi;
        $action_url .='&campaignId='.$currentcampaignId;
        $hidden=array('tableName'=>'spider_'.$currentApi,'apiName'=>$currentApi);
        //$hidden=array('apiName'=>$currentApi);
?>
<?php echo form_open($action_url, '',$hidden);?>
<div class="formArea">
    <div>
        <div class="templateEditorTop">
            <h2>Choose Api</h2>
            <div class="search">
                <?php echo form_label("Select campaign", 'campaign_id');?>
                <select name="campaign_id" onchange="location = '<?php echo BASE.AMP.$changeUrl.'&campaignId=';?>'+this.options[this.selectedIndex].value;">
                        <?php foreach ($campaigns as $campaign):?>
                                <option value="<?php echo $campaign['campaign_id'];?>" <?php if ($campaign['campaign_id']==$currentcampaignId){echo 'selected="selected"';}?> ><?php echo $campaign['campaign_name'];?></option>
                        <?php endforeach;?>
                </select>
            </div>
        </div>
    </div>
    <div id="templateGroups">
        <div class="column">
            <?php if($sucessMsg): ?>
            <div class="linkBar">
                <p class="go_notice"><?php echo $sucessMsg;?></p>
            </div>
            <?php endif; ?>
            <div class="formHeading">
                <span>Apis</span>
            </div>
            <div class="groupList">
                
                <ul id="sortable_template_groups" class="ui-sortable">
                    <?php foreach ($selectedApis as $api):?>
	 		<li <?php if($api==$currentApi):?>class="selected"<?php endif;?>>
                            <a href="<?php echo BASE.AMP.'C=addons_modules'.AMP.'M=show_module_cp'
					.AMP.'module=spider'.AMP.'method=apiConfigure&api='.$api.AMP.'campaignId='.$currentcampaignId;?>"
					class="<?php echo $api;?> templateGroupName" >
					<?php echo $apiNames[$api];?>
                            </a>
                        </li>
                    <?php endforeach;?>
                </ul>
            </div>
        </div>
    </div>
    <div id="templates">
        <div class="column">
            
            <div class="linkBar">
                
            </div>
            <div class="templateGrouping" style="display: block;">
                <div class="formHeading">
                    <span>Configure <?php echo $apiNames[$currentApi];?></span>
                </div>
                <table cellspacing="0" cellpadding="0" border="0" class="templateTable">
                    <thead>
                        <tr>
                            <th>Options</th>
                            <th>Value</th>
                        </tr>
                    </thead>
                    <tbody>
                        <?php foreach ($optionArray as $key=>$value): ?>
                        <tr>
                          
                            <td>
                                <?php echo form_label($value['label'], $key); ?>
                            </td>
                            

                            <td>
                                <?php
                                if ($value['type']=='form_dropdown' || $value['type']=='form_multiselect'){
                                        $selected=(isset($value['attribute']['value']))?$value['attribute']['value']:null;
                                        unset($value['attribute']['value']);
                                        echo $value['type']($value['name'],$value['attribute'], $selected, $value['other']);
                                }
                                else{
                                        if($value['type']=='form_checkbox'){    
                                            echo form_hidden($value['attribute']['name'], $value['attribute']['value']);
                                        }
                                        echo $value['type']($value['attribute']);
                                        echo form_error($value['attribute']['name']);
                                }
                                ?>
                            </td>
                        </tr>
                        <?php endforeach;?>
                    </tbody>
                </table>
                <p style="float:right"><?php echo form_submit(array('name'=>'optionSave', 'value'=>'Save', 'class' => 'submit'));?></p>
            </div>
            <?php echo form_close();?>
        </div>
    </div>
    <div class="clear_left">&nbsp;</div>
</div>